import sys
from pathlib import Path
from omegaconf import OmegaConf

file2 = sys.argv[1]

# 读取配置文件 该配置可被覆盖 , 参数必须是带有=分割的参数，而且不要带-和--
# python 01_配置读取.py ceshi.yaml a=100 model_name_or_path="bbbb"
override_config = OmegaConf.from_cli(sys.argv[2:])
# override_config = OmegaConf.from_cli(["aa=100", "bb=200", "model_name_or_path=bbbbbbbbbb"])
# 使用from_dotlist方法， 参数必须是带有=分割的参数，而且不要带-和--
# override_config = OmegaConf.from_dotlist(["aa=100", "bb=200","model_name_or_path=bbbbbbbbbb"])
# 读取配置文件 该配置不可被覆盖
dict_config = OmegaConf.load(Path(file2).absolute())
print(OmegaConf.to_container(OmegaConf.merge(dict_config, override_config)))
